﻿Esc:: ExitApp()
OnMessage(0x0201, (*) => PostMessage(0xA1, 2))


FrameShadow(HGui) {
  ; makes the captionless window a drop shadow
  ; code borrowed from here: https://www.autohotkey.com/boards/viewtopic.php?t=29117

  DllCall("dwmapi\DwmIsCompositionEnabled", "IntP", &_ISENABLED := 0) ; Get if DWM Manager is Enabled
  if !_ISENABLED ; if DWM is not enabled, Make Basic Shadow
    DllCall("SetClassLong", "UInt", HGui, "Int", -26, "Int", DllCall("GetClassLong", "UInt", HGui, "Int", -26) |
      0x20000)
  else {
    _MARGINS := Buffer(16)
    NumPut("UInt", 1, _MARGINS, 0)
    NumPut("UInt", 1, _MARGINS, 4)
    NumPut("UInt", 1, _MARGINS, 8)
    NumPut("UInt", 1, _MARGINS, 12)
    DllCall("dwmapi\DwmSetWindowAttribute", "Ptr", HGui, "UInt", 2, "Int*", 2, "UInt", 4)
    DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", HGui, "Ptr", _MARGINS.Ptr)
  }
}

TransparentWin(accent_state, hwnd) {
  ;0：表示禁用玻璃效果和透明度，窗口不会有透明效果。
  ;1：表示启用玻璃效果，通常以一种轻度透明的方式呈现窗口。
  ;2：表示启用玻璃效果，通常以更明显的透明方式呈现窗口。
  ;3：表示启用玻璃效果，通常以更明显的透明方式呈现窗口，并带有模糊效果。
  WCA_ACCENT_POLICY := 19, pad := A_PtrSize = 8 ? 4 : 0, gradient_color := "0x01000000"
  ACCENT_POLICY := Buffer(16, 0), WINCOMPATTRDATA := Buffer(4 + pad + A_PtrSize + 4 + pad, 0)

  NumPut("int", (accent_state > 0 && accent_state < 4) ? accent_state : 0, ACCENT_POLICY, 0)
    , NumPut("int", gradient_color, ACCENT_POLICY, 8)
    , NumPut("int", WCA_ACCENT_POLICY, WINCOMPATTRDATA, 0)
    , NumPut("int*", ACCENT_POLICY.ptr, WINCOMPATTRDATA, 4 + pad)
    , NumPut("uint", ACCENT_POLICY.size, WINCOMPATTRDATA, 4 + pad + A_PtrSize)
  DllCall("user32\SetWindowCompositionAttribute", "ptr", hwnd, "ptr", WINCOMPATTRDATA)
}